<?php


class Test
{
    public static function add($path, $to)
    {
        if ($to instanceof Closure) {
            $reflector = new \ReflectionFunction($to);
            if ($reflector->getParameters()) {
                $params = [];
                foreach ($reflector->getParameters() as $p) {
                    $params[]   = $_GET[$p->name] ?? 1;
                }
                return $reflector->invokeArgs($params);
            } else {
                return $reflector->invoke();
            }
        }
        return $to;
    }
}